package hzh;


import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;


@WebServlet(name="VCodeServlet")
public class VCodeServlet extends HttpServlet {

    private static final long serialVersionUID = 119877788866686380L;

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        this.doPost(request, response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        HttpSession session = request.getSession(true);

        ValidateCode coder = new ValidateCode();
        session.setAttribute(AuthFilter.LOGIN_VALIDATE_CODE, coder.getCodeString());//将验证码结果到session中
       response.setContentType("image/png");
        OutputStream out = response.getOutputStream();
       coder.outputCodeImage(out);

    }

}

